<?
	$t_name=$_SESSION[Admin][t_name];
	//$dep_name=$_SESSION[Admin][DepName];
	$shenfen = getNameFromArray($_SESSION[Admin][is_admin],$aListAdmin);
if (!$code || $code=="list")
{
	$code ="list";
	$sql_body = "from news where visible=1 and usertype=2 order by id desc ";
	
	# 分页
	$sql_page = "select count(*) as total " . $sql_body;
	$rs_total = $conn->Execute($sql_page);
	if($rs_total) {
		$TotalNum = $rs_total->fields("total");
	}
	
	$TotalPage = ceil($TotalNum/$RowsPerPage);
	if (!$page || $page < 1) {
		$page = 1;
	}
	if ($page > $TotalPage) {
		$page = $TotalPage;
	}
	
	$page_show = showPage();
	
	# 查询
	$rs = &$conn->PageExecute("select * " . $sql_body, $RowsPerPage, $page);
}
elseif ($code=="view")
{
	if (!$id) {
		adminmsg("参数错误！");
		return;
	}

	$rs = $conn->Execute("select * from news where id=$id");
	$title = $rs->fields("title");
	$content = $rs->fields("content");
	$filename = $rs->fields("filename");

	if ($filename) {
		$alert  = "<a href=\"./inc/getfile.php?NewsID=$id\" target=\"_blank\">$filename</a>";
	}
}
	include printEOT('main');
?>